package top.csjss.hospital.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @Author ztf
 * @Date 11:00 2021/10/20
 * 处理身份证号的序列化工具
 **/
public class HiddenCardIdInformationJsonSerializer extends JsonSerializer<String> {
    @Override
    public void serialize(String value, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String cardId =value.substring(0,4)+"****"+value.substring(value.length()-4);
        jsonGenerator.writeString(cardId);
    }
}
